package snafu.framework.states;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import snafu.framework.senses.stimuli.Stimulus;
import snafu.framework.senses.stimuli.StimulusItself;
import snafu.framework.states.literals.StateLiteral;
import snafu.framework.states.literals.StateLiteralItself;
import snafu.framework.view.Access;
import snafu.framework.view.View;

public class StateView extends AbstractState implements View {

	/** The access type. */
	protected Access access;
	/** The original state. */
	protected StateItself state;
	
	/**
	 * Instantiates a new view of the given state with the given accesss.
	 * 
	 * @param access
	 *            the access type
	 * @param state
	 *            the original state
	 */
	public StateView(Access access, StateItself state) {
		this.access = access;
		this.state = state;
	}

	/**
	 * Returns views of all literals from the original state that have an access lower or equal to
	 * this access.
	 */
	@Override
	public List<StateLiteral<?>> getLiterals() {
		List<StateLiteral<?>> literalViews = new ArrayList<StateLiteral<?>>();
		for (StateLiteralItself<?> literal : state.literals) {
			// add only literals that are below or equal to this views access			
			if (literal.getPrivacy().ordinal() <= access.ordinal()) {
				literalViews.add(literal.createView(access));
			}
		}
		return literalViews;
	}
	
	@Override
	public Set<Stimulus> getStimuli() {
		Set<Stimulus> copiedStimulus = new HashSet<Stimulus>();
		for (StimulusItself stimulus : state.stimuli) {
			copiedStimulus.add(stimulus.createView(access));
		}
		return null;
	}
	
}
